<!--
 * @Description: 推进
 * 
 * @Author: XiongYaoYuan<xiongyaoyuan>
 * @Date: 2023-07-06 19:18:59
 * @FilePath: /yuxiuproweb/src/views/mes/pro/workorder/advance/index.vue
-->
<template>
  <el-dialog
    :close-on-click-modal="false"
    v-dialogDrag
    title="订单推进"
    :visible.sync="shows"
    width="600px"
    append-to-body
  >
    <el-steps :active="active" finish-status="success" align-center>
      <el-step
        v-for="(item, index) in dict.type.pro_order_state"
        :key="item.value"
        :title="item.label"
        :description="
          index < active ? '已完成' : active === index ? '当前状态' : '未完成'
        "
      ></el-step>
    </el-steps>
		
    <div slot="footer" class="dialog-footer">
		<div class="button" style="float: left;" v-if="data.isUsingRebate==1 && [2].includes(active)">
			返利金:<input name="flmoney" v-model="flmoney" placeholder="0.00"/>
		</div>
      <el-button
        type="primary"
        @click="submitForm(active - 1)"
        v-if="[1, 2].includes(active)"
        >回 退</el-button
      >
      <el-button
        type="success"
        @click="submitForm(active + 1)"
        v-if="active !== 4"
        >推 进</el-button
      >
      <el-button @click="shows = false">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { auditOrder } from "@/api/asc/order";
export default {
  dicts: ["pro_order_state"],
  props: {
    show: Boolean,
    type: {
      type: String,
      default: "add",
    },
    data: {
      type: Object,
    },
  },
  data() {
    return {
	  flmoney:0.00,
      active: 0,
	  money:0.00,
    };
  },
  computed: {
    shows: {
      get() {
        return this.show;
      },
      set(newValue) {
        this.$emit("update:show", newValue);
      },
    },
  },
  created() {
    this.active = +this.data.state || 0;
  },
  methods: {
    /** 保存按钮 */
    async submitForm(state) {
			if(state==3){
				this.flmoney=this.flmoney
			}else{
				this.flmoney=0
			}
      try {
        auditOrder({
          orderId: this.data.proOrderId,
		  rebateAmount:this.flmoney,
          state,
        }).then(() => {
          this.$modal.msgSuccess("操作成功");
          this.shows = false;
          this.$emit("update");
        });
      } catch (e) {
        console.log(e);
      }
    },
  },
};
</script>
